package sctu.edu.java.year2016.team02.wanggaowen.day20160604.Chapter12_3;



import sctu.edu.java.year2016.team02.wanggaowen.Rewrite.MyWrite;

import java.io.*;
import java.util.Scanner;

/**
 * Created by 15c on 2016/6/6.
 *///12.3编写程序，实现当用户输入姓名和密码时，将每一个姓名和密码加在文件中。

public class Work12_3  {
    public static void main(String[] args)  {
        Scanner scan=new Scanner(System.in);
        File file=new File("E://Work12_3.txt");

        System.out.println("请输入用户名");
        String name =scan.nextLine();

        System.out.println("请输入密码");
        String secret= scan.nextLine();
        String a="用户名：";
        String b="密码：";

        try {
            if (!file.exists()){file.createNewFile();}
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            FileWriter fileWriter=new FileWriter(file);
            fileWriter.write(a);
            fileWriter.write(name);
            fileWriter.write(b);
            fileWriter.write(secret);
            fileWriter.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }





